package com.forecasting.unittest;

import static org.junit.Assert.*;

import org.junit.Test;

import com.forecasting.model.PartNumber;

public class PartNumberTest {
	PartNumber pn1 = null;
	PartNumber pn2 = null;
	PartNumber pn3 = null;
	
	public void initialValue(){
		pn1 = new PartNumber("333-444-0","Plates","Wings skin plates",1,1,2,0.2);
		pn2 = new PartNumber("   333-444-0   ","   PLATES   ","   Wings skin plates   ",1,1,2);
		pn3 = new PartNumber("345-444-3","DAU","boring computer",1,2,2,0.3);
	}
	@Test
	public void testConstructor(){
		assertNull(pn1);
		assertNull(pn2);
		assertNull(pn3);
		initialValue();
		
		assertTrue(pn1.getForecast() == 1);
		assertTrue(pn1.getLeadtime() == 1);
		assertTrue(pn1.getRop() == 2);
		assertTrue(pn1.getStandardDeviation() == 0.2);
		
		assertTrue(pn1.getUniqueID().equalsIgnoreCase("333-444-0"));
		assertTrue(pn1.getName().equalsIgnoreCase("Plates"));
		assertTrue(pn1.getDescription().equals("Wings skin plates"));
		
		assertTrue(pn2.getStandardDeviation() == 0);
		
		//verify trim function
		assertTrue(pn2.getUniqueID().equalsIgnoreCase("333-444-0"));
		assertTrue(pn2.getName().equals("PLATES"));
		assertTrue(pn2.getDescription().equals("Wings skin plates"));
	}
	@Test
	public void testCompareTo(){
		initialValue();
		assertTrue(pn1.compareTo(pn2) == 0);
		assertTrue(pn1.compareTo(pn3) != 0);
	}
	@Test
	public void testToString(){
		initialValue();
		assertTrue(pn1.toString().equals("ID: 333-444-0 Name: Plates Desc.: Wings skin plates"));
	}
}
